package com.example.dreamwork;

import java.util.ArrayList;
import java.util.List;

import com.example.dreamwork.activity.viewpager.TransformViewPagerActivity;
import com.example.dreamwork.adapter.MyBaseExpandListAdapter;
import com.example.dreamwork.service.notification.NotificationActivity;
import com.example.dreamwork.service.services.IntentServiceActivity;
import com.example.dreamwork.service.services.ServiceActivity;
import com.example.dreamwork.util.V;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.OnChildClickListener;

public class MainActivity extends Activity {
	private Context mContext;
	private ExpandableListView expandableListView;
	private List<String> components = new ArrayList<String>();
	private List<List<Class>> activities = new ArrayList<>();
	private MyBaseExpandListAdapter adapter;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		mContext = this;
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
		setContentView(R.layout.activity_main);
		initDatas();
		InitView();
		Log.e("ll", "aaaaaaaaaa");
	}

	private void initDatas() {
		// TODO Auto-generated method stub
		components.add("ViewPager");
		components.add("Service");

		List<Class> activity1 = new ArrayList<>();
		activity1.add(TransformViewPagerActivity.class);

		List<Class> activity2 = new ArrayList<>();
		activity2.add(NotificationActivity.class);
		activity2.add(ServiceActivity.class);
		activity2.add(IntentServiceActivity.class);

		activities.add(activity1);
		activities.add(activity2);

	}

	private void InitView() {
		// TODO Auto-generated method stub
		expandableListView = V.f(this, R.id.list);
		expandableListView.setGroupIndicator(null);
		adapter = new MyBaseExpandListAdapter(mContext, components, activities);
		expandableListView.setAdapter(adapter);
		expandableListView.setOnChildClickListener(new OnChildClickListener() {

			@Override
			public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition,
					long id) {
				// TODO Auto-generated method stub
				Class activty = activities.get(groupPosition).get(childPosition);
				Intent intent = new Intent(mContext, activty);
				startActivity(intent);
				return true;
			}
		});
	}

}
